package com.numberone.master.common.Interface;

import java.util.HashMap;
import java.util.Map;
import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.numberone.master.common.utils.HttpClientUtil;

/**
 * 山东移动物联网接口
 * @auto人 ck
 *
 * @dateTime 2018年3月1日下午2:30:47
 */
public class ShanDong {
	//账号
	private static final String APP_KEY = "njsyzwlk";
	
	private static final String TOKEN = "b64b59e83b267708f56f1273393b81a6b4b583133fdb06d1a0649f888d93aa61";

	/**订购套餐查询**/
	private static final String qrySubsPackage = "http://223.99.141.141:10110/sdiot/bossopen/qrySubsPackage";
	/**套餐余量查询**/
	private static final String qryRestOfPackage = "http://223.99.141.141:10110/sdiot/bossopen/qryRestOfPackage";
	/**实时余额查询**/
	private static final String qrySubsBalance = "http://223.99.141.141:10110/sdiot/bossopen/qrySubsBalance";
	/**实时话费查询 2.当月账单查询**/
	private static final String qryRealTimeBill = "http://223.99.141.141:10110/sdiot/bossopen/qryRealTimeBill";
	/**1.激活日期查询 2.开户日期查询 3.用户信息查询**/
	private static final String qryUserInfo = "http://223.99.141.141:10110/sdiot/bossopen/qryUserInfo";
	/**IMEI信息查询**/
	private static final String qryTelImeiInfo = "http://223.99.141.141:10110/sdiot/sdiotopen/qryTelImeiInfo";
	/**码号信息查询**/
	private static final String qryNumberInfo = "http://223.99.141.141:10110/sdiot/cmiotopen/qryNumberInfo";
	/**1.历史日流量查询 2.历史上行日流量查询 3.历史下行日流量查询 4.历史月流量查询 5.历史上行月流量查询 6.历史下行月流量查询 7.历史日流量批量查询**/
	private static final String qryDayGprsUsedInfo = "http://223.99.141.141:10110/sdiot/sdiotopen/qryDayGprsUsedInfo";
	/**实时流量使用查询**/
	private static final String qryGPRSRealTimeInfo = "http://223.99.141.141:10110/sdiot/cmiotopen/qryGPRSRealTimeInfo";
	/**当月GPRS查询**/
	private static final String qryCurMonthGprsUsedInfo = "http://223.99.141.141:10110/sdiot/cmiotopen/qryCurMonthGprsUsedInfo";
	/**流量池信息查询**/
	private static final String qryGPRSPoolInfo = "http://223.99.141.141:10110/sdiot/cmiotopen/qryGPRSPoolInfo";
	/**开关机状态实时查询**/
	private static final String qryOnAndOffRealSingle = "http://223.99.141.141:10110/sdiot/cmiotopen/qryOnAndOffRealSingle";
	/**用户状态信息实时查询**/
	private static final String qryUserStatusRealSingle = "http://223.99.141.141:10110/sdiot/cmiotopen/qryUserStatusRealSingle";
	/**在线信息实时查询**/
	private static final String qryGPRSInfo = "http://223.99.141.141:10110/sdiot/cmiotopen/qryGPRSInfo";
	/**集团GPRS在线数量查询**/
	private static final String qryGprsOnlineCount = "http://223.99.141.141:10110/sdiot/cmiotopen/qryGprsOnlineCount";
	/**用户卡状态实时查询**/
	private static final String qryCardStatusResult = "http://223.99.141.141:10110/sdiot/cmiotopen/qryCardStatusResult";
	/**根据IP地址查询GPRS信息**/
	private static final String qryGprsInfoByIp = "http://223.99.141.141:10110/sdiot/cmiotopen/qryGprsInfoByIp";
	/**订购加油包**/
	private static final String buyFlow = "http://223.99.141.141:10110/sdiot/bossopen/buyFlow";
	/**1.不带号码充值 2.带号码充值**/
	private static final String iotRechargeHome = "http://m.sd.10086.cn/sd_h5_payment/iotRecharge/iotRechargeHome.do";
	/**1.开机功能 2.停机功能**/
	private static final String stopOpenSubs = "http://223.99.141.141:10110/sdiot/bossopen/stopOpenSubs";
	/**取消测试期**/
	private static final String unTest = "http://223.99.141.141:10110/sdiot/bossopen/unTest";
	/**历史月流量批量查询**/
	private static final String qryMonGprsUsedInfo = "http://223.99.141.141:10110/sdiot/sdiotopen/qryMonGprsUsedInfo";
	/**1.批量开机功能 2.批量停机功能 3.批量停开机次月生效功能**/
	private static final String batchStopOpenSubs = "http://223.99.141.141:10110/sdiot/bossopen/batchStopOpenSubs";
	/**服务状态批量查询**/
	private static final String batchQryCardServiceStatus = "http://223.99.141.141:10110/sdiot/cmiotopen/batchQryCardServiceStatus";
	/**在线状态批量查询**/
	private static final String batchQryGprsStatus = "http://223.99.141.141:10110/sdiot/cmiotopen/batchQryGprsStatus";
	/**历史账单推送**/
	private static final String exportOpenApi = "http://223.99.141.141:10110/sdiot/bossopen/exportOpenApi";
	/** 用户使用定位服务**/
	private static final String toPositionApp = "http://223.99.141.141:10110/sdiot/sdiotopen/toPositionApp";
	
	/**
	 * 用户订购套餐查询
	 * @param telnum 手机号码
	 * @return
	 */
	public static String qrySubsPackage(String telnum){
		Map<String,String> map = new HashMap<String,String>();
		map.put("appkey",APP_KEY);
		map.put("telnum", telnum);
		map.put("token", TOKEN);
		String body = HttpClientUtil.doPost(qrySubsPackage, JSON.toJSONString(map));
		return body;
	}
	
	/**
	 * 用户套餐余量查询
	 * @param telnum 手机号码
	 * @return
	 */
	public static String qryRestOfPackage(String telnum){
		Map<String,String> map = new HashMap<String,String>();
		map.put("appkey",APP_KEY);
		map.put("telnum", telnum);
		map.put("token", TOKEN);
		String body = HttpClientUtil.doPost(qryRestOfPackage, JSON.toJSONString(map));
		return body;
	}
	
	/**
	 * 用户余额查询
	 * @param telnum 手机号码
	 * @return
	 */
	public static String qrySubsBalance(String telnum){
		Map<String,String> map = new HashMap<String,String>();
		map.put("appkey",APP_KEY);
		map.put("telnum", telnum);
		map.put("token", TOKEN);
		String body = HttpClientUtil.doPost(qrySubsBalance, JSON.toJSONString(map));
		return body;
	}
	
	/**
	 * 实时流量使用查询
	 * @param queryNum  查询号码
	 * @param numType 所查询的号码类型。1：msisdn（物联网卡号） 对应查询中移物联网接口；2：telnum(手机号) 对应查询BOSS接口。
	 * @param provinceid 省编码
	 * @return
	 */
	public static String qryGPRSRealTimeInfo(String queryNum,String numType,String provinceid){
		Map<String,Object> map = new HashMap<String,Object>();
		map.put("appkey",APP_KEY);
		map.put("token", TOKEN);
		map.put("numType", numType);
		map.put("queryNum", queryNum);
		map.put("provinceid", provinceid);
		String body = HttpClientUtil.doPost(qryGPRSRealTimeInfo, JSON.toJSONString(map));
		return body;
	}
	
	/**
	 * 省公司客户流量池信息查询
	 * @param queryDate 查询月份，时间精确到月,不输入则默认上月
	 * @param provinceid 省份编码
	 * @param custid 省份下的企业客户编号
	 * @return
	 */
	public static String qryGPRSPoolInfo(String queryDate,String provinceid,String custid){
		Map<String,String> map = new HashMap<String,String>();
		map.put("appkey",APP_KEY);
		map.put("token", TOKEN);
		map.put("queryDate", queryDate);
		map.put("provinceid", provinceid);
		map.put("custid", custid);
		String body = HttpClientUtil.doPost(qryGPRSPoolInfo, JSON.toJSONString(map));
		return body;
	}
	
	/**
	 * 省公司IP地址查询GPRS信息
	 * @param ip ip地址
	 * @param provinceid 省编码
	 * @return
	 */
	public static String qryGprsInfoByIp(String ip,String provinceid){
		Map<String,String> map = new HashMap<String,String>();
		map.put("appkey",APP_KEY);
		map.put("token", TOKEN);
		map.put("ip", ip);
		map.put("provinceid", provinceid);
		String body = HttpClientUtil.doPost(qryGprsInfoByIp, JSON.toJSONString(map));
		return body;
	}
	
	/**
	 * 省用户当月GPRS查询
	 * @param numType 所查询的号码类型。
	 * @param queryNum 所查询的号码
	 * @param provinceid 省编码
	 * @return
	 */
	public static String qryCurMonthGprsUsedInfo(String queryNum,String numType,String provinceid){
		Map<String,String> map = new HashMap<String,String>();
		map.put("appkey",APP_KEY);
		map.put("token", TOKEN);
		map.put("numType", numType);
		map.put("queryNum", queryNum);
		map.put("provinceid", provinceid);
		String body = HttpClientUtil.doPost(qryCurMonthGprsUsedInfo, JSON.toJSONString(map));
		return body;
	}
	
	/**
	 * 集团GPRS在线数实时查询
	 * @param ecid 企业编号
	 * @param ecname 企业客户名
	 * @param provinceid 省编号
	 * @return
	 */
	public static String qryGprsOnlineCount(String ecid,String ecname,String provinceid){
		Map<String,String> map = new HashMap<String,String>();
		map.put("appkey",APP_KEY);
		map.put("token", TOKEN);
		map.put("ecid", ecid);
		map.put("ecname", ecname);
		map.put("provinceid", provinceid);
		String body = HttpClientUtil.doPost(qryGprsOnlineCount, JSON.toJSONString(map));
		return body;
	}
	
	/**
	 * 
	 * @param date 日期：格式为yyyyMMdd，日期不能大于等于当天的日期
	 * @param groupid 集团编码，集团编码和用户号码不能全部为空
	 * @param telnum 用户号码多个用户号码用','号分隔，列如1064848449908,1064848449907
	 * @return
	 */
	public static String qryDayGprsUsedInfo(String date,String groupid,String telnum){
		Map<String,String> map = new HashMap<String,String>();
		map.put("appkey",APP_KEY);
		map.put("token", TOKEN);
		map.put("date", date);
		map.put("groupid", groupid);
		map.put("telnum", telnum);
		String body = HttpClientUtil.doPost(qryDayGprsUsedInfo, JSON.toJSONString(map));
		return body;
	}
	
	/**
	 * 
	 * @param date 月份：格式为yyyyMM，月份不能大于等于当月
	 * @param groupid 集团编码，集团编码和用户号码不能全部为空
	 * @param telnum 用户号码多个用户号码用','号分隔，列如1064848449908,1064848449907
	 * @return
	 */
	public static String qryMonGprsUsedInfo(String date,String groupid,String telnum){
		Map<String,String> map = new HashMap<String,String>();
		map.put("appkey",APP_KEY);
		map.put("token", TOKEN);
		map.put("date", date);
		map.put("groupid", groupid);
		map.put("telnum", telnum);
		String body = HttpClientUtil.doPost(qryMonGprsUsedInfo, JSON.toJSONString(map));
		return body;
	}
	
	/**
	 * 省公司开关机状态实时查询
	 * @param msisdn 所查询的专网号码
	 * @param provinceid 省编码
	 * @return
	 */
	public static String qryOnAndOffRealSingle(String msisdn,String provinceid){
		Map<String,String> map = new HashMap<String,String>();
		map.put("appkey",APP_KEY);
		map.put("token", TOKEN);
		map.put("msisdn", msisdn);
		map.put("provinceid", provinceid);
		String body = HttpClientUtil.doPost(qryOnAndOffRealSingle, JSON.toJSONString(map));
		return body;
	}
	
	/**
	 * 省公司用户卡状态实时查询
	 * @param msisdn 所查询的专网号码
	 * @param provinceid 省编码
	 * @return
	 */
	public static String qryCardStatusResult(String msisdn,String provinceid){
		Map<String,String> map = new HashMap<String,String>();
		map.put("appkey",APP_KEY);
		map.put("token", TOKEN);
		map.put("msisdn", msisdn);
		map.put("provinceid", provinceid);
		String body = HttpClientUtil.doPost(qryCardStatusResult, JSON.toJSONString(map));
		return body;
	}
	
	/**
	 * 省公司用户状态信息实时查询
	 * @param msisdn 所查询的专网号码
	 * @param provinceid 省编码
	 * @return
	 */
	public static String qryUserStatusRealSingle(String msisdn,String provinceid){
		Map<String,String> map = new HashMap<String,String>();
		map.put("appkey",APP_KEY);
		map.put("token", TOKEN);
		map.put("msisdn", msisdn);
		map.put("provinceid", provinceid);
		String body = HttpClientUtil.doPost(qryUserStatusRealSingle, JSON.toJSONString(map));
		return body;
	}
	
	/**
	 * 省公司在线信息实时查询
	 * @param msisdn 所查询的专网号码
	 * @param provinceid 省编码
	 * @return
	 */
	public static String qryGPRSInfo(String msisdn,String provinceid){
		Map<String,String> map = new HashMap<String,String>();
		map.put("appkey",APP_KEY);
		map.put("token", TOKEN);
		map.put("msisdn", msisdn);
		map.put("provinceid", provinceid);
		String body = HttpClientUtil.doPost(qryGPRSInfo, JSON.toJSONString(map));
		return body;
	}
	
	/**
	 * 物联卡服务状态批量查询
	 * @param numType 所查询的号码类型
	 * @param queryNum 所查询的号码
	 * @param provinceid 省编码
	 * @return
	 */
	public static String batchQryCardServiceStatus(String numType,String queryNum,String provinceid){
		Map<String,String> map = new HashMap<String,String>();
		map.put("appkey",APP_KEY);
		map.put("token", TOKEN);
		map.put("numType", numType);
		map.put("queryNum", queryNum);
		map.put("provinceid", provinceid);
		String body = HttpClientUtil.doPost(batchQryCardServiceStatus, JSON.toJSONString(map));
		return body;
	}
	
	/**
	 * 在线状态批量查询
	 * @param numType 所查询的号码类型
	 * @param queryNum 所查询的号码
	 * @param provinceid 省编码
	 * @return
	 */
	public static String batchQryGprsStatus(String numType,String queryNum,String provinceid){
		Map<String,String> map = new HashMap<String,String>();
		map.put("appkey",APP_KEY);
		map.put("token", TOKEN);
		map.put("numType", numType);
		map.put("queryNum", queryNum);
		map.put("provinceid", provinceid);
		String body = HttpClientUtil.doPost(batchQryGprsStatus, JSON.toJSONString(map));
		return body;
	}
	
	/**
	 * 用户信息查询
	 * @param telnum 用户信息查询
	 * @return
	 */
	public static String qryUserInfo(String telnum){
		Map<String,String> map = new HashMap<String,String>();
		map.put("appkey",APP_KEY);
		map.put("token", TOKEN);
		map.put("telnum", telnum);
		String body = HttpClientUtil.doPost(qryUserInfo, JSON.toJSONString(map));
		return body;
	}
	
	/**
	 * 省公司号码信息查询
	 * @param numType 所查询的号码类型。
	 * @param queryNum 所查询的号码
	 * @param provinceid 省编码
	 * @return
	 */
	public static String qryNumberInfo(String numType,String queryNum,String provinceid){
		Map<String,String> map = new HashMap<String,String>();
		map.put("appkey",APP_KEY);
		map.put("token", TOKEN);
		map.put("numType", numType);
		map.put("queryNum", queryNum);
		map.put("provinceid", provinceid);
		String body = HttpClientUtil.doPost(qryNumberInfo, JSON.toJSONString(map));
		return body;
	}
	
	/**
	 * 
	 * @param telnum 手机号码
	 * @param stoptype 停开机操作类型 StopSubs：申请停机 OpenSubs：申请开机
	 * @param needPwd 停开机是否进行身份验证 1验证  0不验证
	 * @param password 服务密码，needPwd为1时，必填
	 * @param certid 证件号码，needPwd为1时，必填
	 * @param changeReason 停开机原因
	 * @return
	 */
	public static String stopOpenSubs(String telnum,String stoptype,String needPwd,String password,String certid,String changeReason){
		Map<String,String> map = new HashMap<String,String>();
		map.put("appkey",APP_KEY);
		map.put("token", TOKEN);
		map.put("telnum", telnum);
		map.put("needPwd", needPwd);
		map.put("password", password);
		map.put("certid", certid);
		map.put("changeReason", changeReason);
		String body = HttpClientUtil.doPost(stopOpenSubs, JSON.toJSONString(map));
		return body;
	}
	
	/**
	 * 用户使用定位服务
	 * @param telnum 手机号码
	 * @return
	 */
	public static String toPositionApp(String telnum){
		Map<String,String> map = new HashMap<String,String>();
		map.put("appkey",APP_KEY);
		map.put("token", TOKEN);
		map.put("telnum", telnum);
		String body = HttpClientUtil.doPost(toPositionApp, JSON.toJSONString(map));
		return body;
	}
	
	/**
	 * 用户查询IMEI号码
	 * @param telNumList 手机号码(最多支持300个号码)
	 * @return
	 */
	public static String qryTelImeiInfo(String[] telNumList){
		Map<String,Object> map = new HashMap<String,Object>();
		map.put("appkey",APP_KEY);
		map.put("token", TOKEN);
		map.put("telNumList", telNumList);
		String body = HttpClientUtil.doPost(qryTelImeiInfo, JSON.toJSONString(map));
		return body;
	}
	
	/**
	 * 订购加油包
	 * @param tel 手机号码
	 * @param flowType 订购加油包套餐：F.000001 100M/10元  F.000002 5G/40元
	 * @return
	 */
	public static String buyFlow(String tel,String flowType){
		Map<String,String> map = new HashMap<String,String>();
		map.put("appkey",APP_KEY);
		map.put("token", TOKEN);
		map.put("tel", tel);
		String body = HttpClientUtil.doPost(buyFlow, JSON.toJSONString(map));
		return body;
	}
	
	/**
	 * 3.7.2.取消测试期
	 * @param tel 手机号码
	 * @return
	 */
	public static String unTest(String tel){
		Map<String,String> map = new HashMap<String,String>();
		map.put("appkey",APP_KEY);
		map.put("token", TOKEN);
		map.put("tel", tel);
		String body = HttpClientUtil.doPost(unTest, JSON.toJSONString(map));
		return body;
	}
	
	/**
	 * 实时话费账单查询
	 * @param telnum 手机号码
	 * @param cycleoffset 账期偏移量，0表示当前账期
	 * @return
	 */
	public static String qryRealTimeBill(String telnum,String cycleoffset){
		Map<String,String> map = new HashMap<String,String>();
		map.put("appkey",APP_KEY);
		map.put("token", TOKEN);
		map.put("cycleoffset", cycleoffset);
		map.put("telnum", telnum);
		String body = HttpClientUtil.doPost(qryRealTimeBill, JSON.toJSONString(map));
		return body;
	}
	
	public static void main(String[] args) throws JsonProcessingException {
		
		System.out.println(qryCurMonthGprsUsedInfo("1440195505670","1","531"));//实时流量使用查询
	}
	
}
